const EventEmitter = require('events');

class Radio extends EventEmitter {
    constructor(name, frequency) {
        super();
        this.name = name;
        this.frequency = frequency;
    }

    play() {
        this.emit('play', `${this.name} FM ${this.frequency} opened`);
        // 模拟播放音乐
        setTimeout(() => {
            console.log('lalala...');
        }, 1000);
    }

    stop() {
        this.emit('stop', `${this.name} FM ${this.frequency} closed`);
    }
}

module.exports = Radio;